<p>This rule raises an issue when <code>fetch()</code> or <code>new Request()</code> is called with a body option while using GET or HEAD methods.</p>
<h2>Why is this an issue?</h2>
<p>The HTTP specification defines that GET and HEAD requests should not contain a request body. When you provide a body with these methods, the Fetch
API throws a <code>TypeError</code> at runtime.</p>
<p>GET requests are designed to retrieve data from a server without modifying anything. Including a body contradicts this purpose and violates HTTP
standards. Similarly, HEAD requests are meant to retrieve only headers, making a body meaningless.</p>
<p>When no method is specified in fetch options, GET is used by default. This means that providing a body without explicitly setting a method like
POST will also cause the same error.</p>
<p>This issue typically occurs when developers copy request code between different HTTP methods without adjusting the options appropriately.</p>
<h3>What is the potential impact?</h3>
<p>This code will throw a <code>TypeError</code> at runtime, causing the application to crash or behave unexpectedly. Users may experience broken
functionality, and the error might not be caught during development if the problematic code path isn’t tested thoroughly.</p>
<h3>How to fix?</h3>
<p>Remove the body option when using GET requests (default method).</p>
<h4>Non-compliant code example</h4>
<pre data-diff-id="1" data-diff-type="noncompliant">
const response = await fetch('/', {body: 'foo=bar'}); // Noncompliant
</pre>
<h4>Compliant code example</h4>
<pre data-diff-id="1" data-diff-type="compliant">
const response = await fetch('/');
</pre>
<h3>Documentation</h3>
<ul>
  <li> <a href="https://github.com/sindresorhus/eslint-plugin-unicorn#readme">eslint-plugin-unicorn</a> - Rule <a
  href="https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/no-invalid-fetch-options.md">no-invalid-fetch-options</a> </li>
  <li> MDN - fetch() - <a href="https://developer.mozilla.org/en-US/docs/Web/API/fetch">Complete documentation for the Fetch API</a> </li>
  <li> MDN - Request constructor - <a href="https://developer.mozilla.org/en-US/docs/Web/API/Request/Request">Documentation for the Request
  constructor</a> </li>
  <li> HTTP request methods - <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods">Overview of HTTP request methods and their
  purposes</a> </li>
</ul>
<h3>Standards</h3>
<ul>
  <li> RFC 7231 - HTTP/1.1 Semantics - <a href="https://tools.ietf.org/html/rfc7231#section-4.3.1">HTTP specification defining GET request
  semantics</a> </li>
</ul>
